package Main;

import java.util.ArrayList;

import Maze.HorizontalTile;
import Maze.Mouse;
import Maze.VerticalTile;

public class DrawNewMaze {
	/**
	 * 
	 * @param mouse
	 *            the new position of the mouse
	 * @param verticalTiles
	 *            the updated arraylist of the vertical tiles
	 * @param horizontalTiles
	 *            the updated arraylist of the horizontal tiles
	 * @return returns the grid after drawing a new one with the updated values
	 *         of the positions of the mouse,vertical and horizontal tiles
	 */

	public static String[][] drawMaze(Mouse mouse,
			ArrayList<VerticalTile> verticalTiles,
			ArrayList<HorizontalTile> horizontalTiles) {

		String[][] grid = new String[6][6];

		mouse.setName("M ");

		grid[mouse.getStartX()][mouse.getEndY()] = "M ";
		grid[mouse.getEndX()][mouse.getEndY()] = "M ";

		for (VerticalTile verticalTile : verticalTiles) {

			grid[verticalTile.getStartX()][verticalTile.getStartY()] = verticalTile
					.getName();
			grid[verticalTile.getEndX()][verticalTile.getEndY()] = verticalTile
					.getName();
			if (verticalTile.getLength() == 3) {
				grid[verticalTile.getStartX()][verticalTile.getEndY() - 1] = verticalTile
						.getName();
			}

		}

		for (HorizontalTile horizontalTile : horizontalTiles) {

			grid[horizontalTile.getStartX()][horizontalTile.getStartY()] = horizontalTile
					.getName();
			grid[horizontalTile.getEndX()][horizontalTile.getStartY()] = horizontalTile
					.getName();

		}

		for (int i = 0; i < 6; i++) {
			for (int j = 0; j < 6; j++) {
				if (grid[i][j] == null) {
					grid[i][j] = ". ";
				}
			}
		}

		return grid;
	}

}
